<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="CSS/style.css">
<link rel="stylesheet" type="text/css" href="CSS/add.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>跳转页面</title>
</head>
<body>
	<h1>Person信息</h1>

	<div id="resdiv">
		<table class="admintable" id="table1">
			<tr>
				<th width="5%" class="adminth">ID</th>
				<th width="25%" class="adminth">姓名</th>
				<th width="10%" class="adminth">年龄</th>
				<th width="5%" class="adminth">性别</th>
				<th width="50%" class="adminth">地址</th>
				<th width="5%" class="adminth">操作</th>
			</tr>
			<tr style="display: none;">
				<td align="center" class="admincls0"></td>
				<td align="center" class="admincls0"></td>
				<td align="center" class="admincls0"></td>
				<td align="center" class="admincls0"></td>
				<td align="center" class="admincls0"></td>
				<td align="center" class="admincls0"><a href="">删除</a></td>
			</tr>

			<c:forEach var="ii" items="${strx}">
				<tr>
					<td align="center" class="admincls0">${ii.id }</td>
					<td align="center" class="admincls0">${ii.user_name }</td>
					<td align="center" class="admincls0">${ii.age }</td>
					<td align="center" class="admincls0"><c:if test="${ii.sex==1}">男</c:if>
						<c:if test="${ii.sex==2}">女</c:if></td>
					<td align="center" class="admincls0">${ii.addr }</td>
					<td align="center" class="admincls0"><a href="" class="delete">删除</a></td>
				</tr>
			</c:forEach>
		</table>
	</div>

	<div class="right">
		<p>
			<input type="button" value="增加" id="add" class="button"> <input
				type="button" value="搜索" id="find" class="button"> <input
				type="button" value="test" id="test" class="button">
		</p>
	</div>

	<div class="right" ,id="finddiv">
		您要查找人的ID: <input type="text" id="fid" name="fid">
	</div>
	<div style="float: right">

		<ul>
		<li><a id="fli">首页</a></li>
		<li><a id="pgli">上一组</a></li>
		<li><a id="pli">前一页</a></li>
		<li id="test2"></li>
		<li><a id="bli">后一页</a></li>
		<li><a id="bgli" href="#">下一组</a></li>
		<!--<li><input type="button" value="下一组" id="bgli"></li>  -->
		<li><a id="lli">末页</a></li>
		</ul>

	</div>
	<div id="divjson"></div>



	<div id="global" class="center" style="display: none;">
		<form id="form1">
			<fieldset>
				<legend>Add a Person</legend>
				<p>
					<label for="name">Person Name: </label> <input type="text"
						id="name" name="name" tabindex="1">
				</p>
				<p id="p">
					<label for="sex">Sex: </label> <input class="sex" type="radio"
						value="1" name="sex" tabindex="2">男 <input class="sex"
						type="radio" value="2" name="sex" tabindex="2">女
				</p>
				<p>
					<label for="age">Age: </label> <input type="text" id="age"
						name="age" tabindex="3">
				</p>
				<p>
					<label for="addr">Addr: </label> <input type="text" id="addr"
						name="addr" tabindex="4">
				</p>
				<p id="buttons">
					<input id="reset" type="reset" tabindex="5" value="  Reset  ">
					<input id="subadd" type="button" tabindex="6" value="Add Person">
					<input type="hidden" value="0" id="hide" class="button">
				</p>
			</fieldset>
		</form>
	</div>


	
	<script src="JS/jquery-1.10.0.js"></script>
	<script src="JS/message.js"></script>
	<script src="JS/add.js"></script>





	<script>
		function backpage(){
			var wls = window.location.search;
			var wlsarr = wls.split('=');
		 	return parseInt(wlsarr[1])+1;
		}
		
		function prepage(){
			var wls = window.location.search;
			var wlsarr = wls.split('=');
		 	return parseInt(wlsarr[1])-1;
		}
		
		
		
		function pagelist(nowgroup,num){
			for (var i = nowgroup*10+1; i <= num; i++) {
				var $li = $('<li><a href="" ></a></li>').appendTo($('#test2'));
				$('a', $li).attr('href', "page.do?pageid=" + i).html(i);
			}
		}
		
		
		function gpagelist(data){
			var nowgroup=0;
			var maxgroup=data;
			if(nowgroup>maxgroup-2){
				$("#bgli").hide();                                                                                                              
			}  
			if(nowgroup<=0){
				$("#pgli").hide();
			}
			$("#bgli").click(function(){	
				nowgroup++;
				var num = (nowgroup+1)*10;
				if(nowgroup>maxgroup-2){
					$("#bgli").hide();                                                                                                              
				}             
				$("#test2").empty();                      
				pagelist(nowgroup,num);
			});
			$("#pgli").click(function(){
				nowgroup--;
				var num = (nowgroup+1)*10;
				if(nowgroup<=0){
					$("#pgli").hide();
				}
				$("#test2").empty();                      
				pagelist(nowgroup,num);
			})
		}
			
		$(function() {
			$.ajax({
						url : "pagecount.do",
						//data : {cur:1},
						type : "GET",
						dataType : "html",
						success : function(data) {
							const num = Math.max(1, data);
							$("#fli").attr('href',"page.do?pageid=1");
							if(prepage()==0){
								$("#pli").attr("disable",true);
							}
							else{
								$("#pli").attr('href', "page.do?pageid=" + prepage());
							}
							if(backpage()-1==num){
								$("#bli").attr("disable",true);
							}
							else{
								$("#bli").attr('href',"page.do?pageid="+backpage())
							}
							$("#lli").attr('href',"page.do?pageid="+num);
							pagelist(0,num);
							gpagelist(data/10);
							
						}
					});
		});
	</script>



</body>
</html>